﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Deeper.Common;
namespace Deeper.DataAccess
{
    [Serializable]
    public class OrderByClip : IClip
    {
        private static readonly OrderByClip Default = new OrderByClip((string)null);


        private string orderBy;

        /// <summary>
        /// 自定义一个OrderBy条件
        /// </summary>
        /// <param name="orderBy"></param>
        public OrderByClip(string orderBy)
        {
            this.orderBy = orderBy;
        }

        public static bool operator true(OrderByClip right)
        {
            return false;
        }

        public static bool operator false(OrderByClip right)
        {
            return false;
        }

        public static OrderByClip operator &(OrderByClip leftOrder, OrderByClip rightOrder)
        {
            OrderByClip clip = Default.BothClip(leftOrder, rightOrder) as OrderByClip;
            if (clip.IsNotNull()) return clip;
            return new OrderByClip(leftOrder.ToString() + "," + rightOrder.ToString());
        }

        public override string ToString()
        {
            return orderBy;
        }


    }
}
